home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
mail
/
mh
/
contrib
/
jpeek
/
mhall
< prev
next >
Wrap
Text File
|
1992-08-09
|
3KB
|
108 lines
#! /bin/csh -f
# $Header: mhall.csh,v 1.2 88/12/09 05:26:54 jerryp Exp $
#
### mhall - apply a command to some or all of your MH folders.
### Usage: mhall [-r] [-n] [-c command] [command-arg...] [+folder...]
#
# Date: 8 Dec 88 17:27:14 GMT
# From: Wayne Mesard <bbn.com!mesard@bbn.com>
# Organization: Bolt Beranek and Newman Inc., Cambridge MA
# Subject: MHALL - do something to a lot of folders
# Sender: mh-users-request@uci.edu
##
## Here's a little script I whipped up this morning. It repeatedly applies
## a command (with optional arguments) to a bunch of folders. I wrote it
## because I'm forever forgetting where I refile'd a message to the night
## before, and wanted a quick n dirty way to look for it.
##
## The default command and argument are "scan" and "last". The default
## folders are all your top-level folders.
##
## When folders are explicitly named subfolders will also be processed.
## The -n switch prevents this recursion. Conversly, when no folders are
## given, the top-level ones are used. The -r switch will cause subfolders
## to be processed as well. To apply a command other than "scan" use the
## -c switch.
##
## Examples:
## ---------
## mhall first:2 5 +unix +inbox
## Will "scan" the first two messages and message number 5 in +unix,
## +inbox and any subfolders.
##
## mhall -c show
## Show the current message of each top-level folder.
##
## mhall -c folder -pack -r
## Invoke "folder" with the -pack option on every folder and subfolder.
##
## Disclaimer: This is not elegant.
# mhall - apply a command to some or all of your MH folders.
# Copyright (c) 1988 Wayne Mesard
#
# This is free software. It may be reproduced, retransmitted,
# redistributed and otherwise propogated at will, provided that
# this notice remains intact and in place.
#
# Please direct bug reports, code enhancements and comments
# to mesard@BBN.COM.
set mh = /usr/local/mh # WHERE MH COMMANDS LIVE
set tfolders
set args
set cmd
set recurse
set curfolder = `$mh/folder -fast`
while ( X$1 != X )
switch ($1)
case -help:
echo "syntax: `basename $0` [-r] [-n] [-c command] [command-arg...] [+folder...]"
exit 0
case -c:
set cmd = "$2"
shift
breaksw
case -r:
set recurse = "-recurse"
breaksw
case -n:
set recurse = "-norecurse"
breaksw
case +*:
set tfolders = "$tfolders $1"
breaksw
default:
set args = "$args $1"
breaksw
endsw
shift
end
if ("$tfolders" == "") then
set folders = `$mh/folders $recurse -fast`
else
set folders
foreach folder ($tfolders)
set folders = "$folders `$mh/folder $folder -recurse $recurse -fast`"
end
endif
if ("$cmd" == "") then
set cmd = "$mh/scan"
if ("$args" == "") set args = "last"
endif
onintr CLEANUP
foreach folder ($folders)
echo :${folder}:
# DON'T USE $mh/ HERE; $cmd MIGHT BE IN ANOTHER DIRECTORY:
$cmd +$folder $args
end
CLEANUP:
$mh/folder +$curfolder >/dev/null
exit 0